<?php
/*******************************************************************************
 * $Date:: Jan 10, 2011 10:20:33 PM                                            $
 * $Revision:                                                                  $
 * $Author:: Tuan Duong                                                        $
 * $Comment::                                                                  $
 ******************************************************************************/ 
/**
 * Description here...
 * 
 * @package Lua
 * @subpackage ##Subpackage##
 * @author Hung Le<hunglevn[at]gmail[dot]com>
 * @version 
 */

class Lua_Service_Friend implements Lua_Service_Interface
{
    /**
     * @var Lua_Table_Friend
     */
    /*private $friendTable = null;
    
    public function __construct()
    {
        $this->friendTable = new Lua_Table_Friend();
    }*/
    
	public function findFriendsOfUser($userId) {
		$db = Zend_Db_Table::getDefaultAdapter();
		$select = $db->select()
		             ->from(array('f' => 'ipoo_friend'),
		                    array())
		             ->join(array('u' => 'ipoo_user'),
		                    'f.friend_id = u.id',
		             		array('u.*'))
		             ->where('f.user_id=?', $userId);
		$stmt = $db->query($select);
		$friends = $stmt->fetchAll();
		return $friends;
	}
	
	public function deleteFriendOfUser($userId, $friendId) {
		$db = Zend_Db_Table::getDefaultAdapter();
		$db->delete('ipoo_friend', 
					array('user_id' => $userId,
							'friend_id' => $friendId));
	}
}